package com.example.day8view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class CustomView extends View {
    private static final String TAG = "TAG";
    //直接new对象创建
    public CustomView(Context context) {
        super(context);
    }

    //自定义View来使用
    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomView);
        String text = typedArray.getString(R.styleable.CustomView_text);
        int color= typedArray.getInt(R.styleable.CustomView_textColor,0);
        int textsize = typedArray.getInt(R.styleable.CustomView_textsize,0);
        Log.i(TAG, "CustomView: "+"     "+text+"     "+color+"     "+textsize);
    }

    //测量        //测量绘制内容的大小，位置
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    }

    //布局
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
    }

    //绘制
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }
}
